﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _11红绿灯状态模式
{
    /// <summary>
    /// 环境类
    /// </summary>
    class TrafficLight
    {
        //LightState[] _states;
        //int index = 0;
        public LightState State { get; set; }
        public TrafficLight()
        {
            State = new RedLightState(this);
            //_states = new LightState[3];
            //_states[0] = new RedLightState();
            //_states[1] = new GreenLightState();
            //_states[2] = new GreenLightState();
            //State = _states[index];    //默认初始化位红灯
        }

        public void SwitchLight()
        {
            //index++;
            //index %= _states.Length;
            //State = _states[index];
        }
    }
}
